package com.cloudloan.common;

import com.cloudloan.utils.AdministratorThreadLocal;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.AsyncHandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@ControllerAdvice
public class GlobalControllerAdvice implements AsyncHandlerInterceptor {
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        // 在请求完成后清理 ThreadLocal
        AdministratorThreadLocal.removeAdministrator();
    }
}
